1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.Paned; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.OrientableIF; 31 private import gtk.OrientableT; 32 private import gtk.Widget; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 private import std.algorithm; 36 37 38 /** 39 * A widget with two panes, arranged either horizontally or vertically. 40 * 41 *  42 * 43 * The division between the two panes is adjustable by the user 44 * by dragging a handle. 45 * 46 * Child widgets are added to the panes of the widget with 47 * [method@Gtk.Paned.set_start_child] and [method@Gtk.Paned.set_end_child]. 48 * The division between the two children is set by default from the size 49 * requests of the children, but it can be adjusted by the user. 50 * 51 * A paned widget draws a separator between the two child widgets and a 52 * small handle that the user can drag to adjust the division. It does not 53 * draw any relief around the children or around the separator. (The space 54 * in which the separator is called the gutter.) Often, it is useful to put 55 * each child inside a [class@Gtk.Frame] so that the gutter appears as a 56 * ridge. No separator is drawn if one of the children is missing. 57 * 58 * Each child has two options that can be set, "resize" and "shrink". If 59 * "resize" is true then, when the `GtkPaned` is resized, that child will 60 * expand or shrink along with the paned widget. If "shrink" is true, then 61 * that child can be made smaller than its requisition by the user. 62 * Setting "shrink" to false allows the application to set a minimum size. 63 * If "resize" is false for both children, then this is treated as if 64 * "resize" is true for both children. 65 * 66 * The application can set the position of the slider as if it were set 67 * by the user, by calling [method@Gtk.Paned.set_position]. 68 * 69 * # CSS nodes 70 * 71 * ``` 72 * paned 73 * ├── <child> 74 * ├── separator[.wide] 75 * ╰── <child> 76 * ``` 77 * 78 * `GtkPaned` has a main CSS node with name paned, and a subnode for 79 * the separator with name separator. The subnode gets a .wide style 80 * class when the paned is supposed to be wide. 81 * 82 * In horizontal orientation, the nodes are arranged based on the text 83 * direction, so in left-to-right mode, :first-child will select the 84 * leftmost child, while it will select the rightmost child in 85 * RTL layouts. 86 * 87 * ## Creating a paned widget with minimum sizes. 88 * 89 * ```c 90 * GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); 91 * GtkWidget *frame1 = gtk_frame_new (NULL); 92 * GtkWidget *frame2 = gtk_frame_new (NULL); 93 * 94 * gtk_widget_set_size_request (hpaned, 200, -1); 95 * 96 * gtk_paned_set_start_child (GTK_PANED (hpaned), frame1); 97 * gtk_paned_set_start_child_resize (GTK_PANED (hpaned), TRUE); 98 * gtk_paned_set_start_child_shrink (GTK_PANED (hpaned), FALSE); 99 * gtk_widget_set_size_request (frame1, 50, -1); 100 * 101 * gtk_paned_set_end_child (GTK_PANED (hpaned), frame2); 102 * gtk_paned_set_end_child_resize (GTK_PANED (hpaned), FALSE); 103 * gtk_paned_set_end_child_shrink (GTK_PANED (hpaned), FALSE); 104 * gtk_widget_set_size_request (frame2, 50, -1); 105 * ``` 106 */ 107 public class Paned : Widget, OrientableIF 108 { 109 /** the main Gtk struct */ 110 protected GtkPaned* gtkPaned; 111 112 /** Get the main Gtk struct */ 113 public GtkPaned* getPanedStruct(bool transferOwnership = false) 114 { 115 if (transferOwnership) 116 ownedRef = false; 117 return gtkPaned; 118 } 119 120 /** the main Gtk struct as a void* */ 121 protected override void* getStruct() 122 { 123 return cast(void*)gtkPaned; 124 } 125 126 /** 127 * Sets our main struct and passes it to the parent class. 128 */ 129 public this (GtkPaned* gtkPaned, bool ownedRef = false) 130 { 131 this.gtkPaned = gtkPaned; 132 super(cast(GtkWidget*)gtkPaned, ownedRef); 133 } 134 135 // add the Orientable capabilities 136 mixin OrientableT!(GtkPaned); 137 138 139 /** */ 140 public static GType getType() 141 { 142 return gtk_paned_get_type(); 143 } 144 145 /** 146 * Creates a new `GtkPaned` widget. 147 * 148 * Params: 149 * orientation = the paned’s orientation. 150 * 151 * Returns: the newly created paned widget 152 * 153 * Throws: ConstructionException GTK+ fails to create the object. 154 */ 155 public this(GtkOrientation orientation) 156 { 157 auto __p = gtk_paned_new(orientation); 158 159 if(__p is null) 160 { 161 throw new ConstructionException("null returned by new"); 162 } 163 164 this(cast(GtkPaned*) __p); 165 } 166 167 /** 168 * Retrieves the end child of the given `GtkPaned`. 169 * 170 * Returns: the end child widget 171 */ 172 public Widget getEndChild() 173 { 174 auto __p = gtk_paned_get_end_child(gtkPaned); 175 176 if(__p is null) 177 { 178 return null; 179 } 180 181 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 182 } 183 184 /** 185 * Obtains the position of the divider between the two panes. 186 * 187 * Returns: the position of the divider, in pixels 188 */ 189 public int getPosition() 190 { 191 return gtk_paned_get_position(gtkPaned); 192 } 193 194 /** 195 * Returns whether the [property@Gtk.Paned:end-child] can be resized. 196 * 197 * Returns: true if the end child is resizable 198 */ 199 public bool getResizeEndChild() 200 { 201 return gtk_paned_get_resize_end_child(gtkPaned) != 0; 202 } 203 204 /** 205 * Returns whether the [property@Gtk.Paned:start-child] can be resized. 206 * 207 * Returns: true if the start child is resizable 208 */ 209 public bool getResizeStartChild() 210 { 211 return gtk_paned_get_resize_start_child(gtkPaned) != 0; 212 } 213 214 /** 215 * Returns whether the [property@Gtk.Paned:end-child] can shrink. 216 * 217 * Returns: true if the end child is shrinkable 218 */ 219 public bool getShrinkEndChild() 220 { 221 return gtk_paned_get_shrink_end_child(gtkPaned) != 0; 222 } 223 224 /** 225 * Returns whether the [property@Gtk.Paned:start-child] can shrink. 226 * 227 * Returns: true if the start child is shrinkable 228 */ 229 public bool getShrinkStartChild() 230 { 231 return gtk_paned_get_shrink_start_child(gtkPaned) != 0; 232 } 233 234 /** 235 * Retrieves the start child of the given `GtkPaned`. 236 * 237 * Returns: the start child widget 238 */ 239 public Widget getStartChild() 240 { 241 auto __p = gtk_paned_get_start_child(gtkPaned); 242 243 if(__p is null) 244 { 245 return null; 246 } 247 248 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 249 } 250 251 /** 252 * Gets whether the separator should be wide. 253 * 254 * Returns: %TRUE if the paned should have a wide handle 255 */ 256 public bool getWideHandle() 257 { 258 return gtk_paned_get_wide_handle(gtkPaned) != 0; 259 } 260 261 /** 262 * Sets the end child of @paned to @child. 263 * 264 * If @child is `NULL`, the existing child will be removed. 265 * 266 * Params: 267 * child = the widget to add 268 */ 269 public void setEndChild(Widget child) 270 { 271 gtk_paned_set_end_child(gtkPaned, (child is null) ? null : child.getWidgetStruct()); 272 } 273 274 /** 275 * Sets the position of the divider between the two panes. 276 * 277 * Params: 278 * position = pixel position of divider, a negative value means that the position 279 * is unset 280 */ 281 public void setPosition(int position) 282 { 283 gtk_paned_set_position(gtkPaned, position); 284 } 285 286 /** 287 * Sets whether the [property@Gtk.Paned:end-child] can be resized. 288 * 289 * Params: 290 * resize = true to let the end child be resized 291 */ 292 public void setResizeEndChild(bool resize) 293 { 294 gtk_paned_set_resize_end_child(gtkPaned, resize); 295 } 296 297 /** 298 * Sets whether the [property@Gtk.Paned:start-child] can be resized. 299 * 300 * Params: 301 * resize = true to let the start child be resized 302 */ 303 public void setResizeStartChild(bool resize) 304 { 305 gtk_paned_set_resize_start_child(gtkPaned, resize); 306 } 307 308 /** 309 * Sets whether the [property@Gtk.Paned:end-child] can shrink. 310 * 311 * Params: 312 * resize = true to let the end child be shrunk 313 */ 314 public void setShrinkEndChild(bool resize) 315 { 316 gtk_paned_set_shrink_end_child(gtkPaned, resize); 317 } 318 319 /** 320 * Sets whether the [property@Gtk.Paned:start-child] can shrink. 321 * 322 * Params: 323 * resize = true to let the start child be shrunk 324 */ 325 public void setShrinkStartChild(bool resize) 326 { 327 gtk_paned_set_shrink_start_child(gtkPaned, resize); 328 } 329 330 /** 331 * Sets the start child of @paned to @child. 332 * 333 * If @child is `NULL`, the existing child will be removed. 334 * 335 * Params: 336 * child = the widget to add 337 */ 338 public void setStartChild(Widget child) 339 { 340 gtk_paned_set_start_child(gtkPaned, (child is null) ? null : child.getWidgetStruct()); 341 } 342 343 /** 344 * Sets whether the separator should be wide. 345 * 346 * Params: 347 * wide = the new value for the [property@Gtk.Paned:wide-handle] property 348 */ 349 public void setWideHandle(bool wide) 350 { 351 gtk_paned_set_wide_handle(gtkPaned, wide); 352 } 353 354 /** 355 * Emitted to accept the current position of the handle when 356 * moving it using key bindings. 357 * 358 * This is a [keybinding signal](class.SignalAction.html). 359 * 360 * The default binding for this signal is <kbd>Return</kbd> or 361 * <kbd>Space</kbd>. 362 */ 363 gulong addOnAcceptPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 364 { 365 return Signals.connect(this, "accept-position", dlg, connectFlags ^ ConnectFlags.SWAPPED); 366 } 367 368 /** 369 * Emitted to cancel moving the position of the handle using key 370 * bindings. 371 * 372 * The position of the handle will be reset to the value prior to 373 * moving it. 374 * 375 * This is a [keybinding signal](class.SignalAction.html). 376 * 377 * The default binding for this signal is <kbd>Escape</kbd>. 378 */ 379 gulong addOnCancelPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 380 { 381 return Signals.connect(this, "cancel-position", dlg, connectFlags ^ ConnectFlags.SWAPPED); 382 } 383 384 /** 385 * Emitted to cycle the focus between the children of the paned. 386 * 387 * This is a [keybinding signal](class.SignalAction.html). 388 * 389 * The default binding is <kbd>F6</kbd>. 390 * 391 * Params: 392 * reversed = whether cycling backward or forward 393 */ 394 gulong addOnCycleChildFocus(bool delegate(bool, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 395 { 396 return Signals.connect(this, "cycle-child-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED); 397 } 398 399 /** 400 * Emitted to cycle whether the paned should grab focus to allow 401 * the user to change position of the handle by using key bindings. 402 * 403 * This is a [keybinding signal](class.SignalAction.html). 404 * 405 * The default binding for this signal is <kbd>F8</kbd>. 406 * 407 * Params: 408 * reversed = whether cycling backward or forward 409 */ 410 gulong addOnCycleHandleFocus(bool delegate(bool, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 411 { 412 return Signals.connect(this, "cycle-handle-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED); 413 } 414 415 /** 416 * Emitted to move the handle with key bindings. 417 * 418 * This is a [keybinding signal](class.SignalAction.html). 419 * 420 * Params: 421 * scrollType = a `GtkScrollType` 422 */ 423 gulong addOnMoveHandle(bool delegate(GtkScrollType, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 424 { 425 return Signals.connect(this, "move-handle", dlg, connectFlags ^ ConnectFlags.SWAPPED); 426 } 427 428 /** 429 * Emitted to accept the current position of the handle and then 430 * move focus to the next widget in the focus chain. 431 * 432 * This is a [keybinding signal](class.SignalAction.html). 433 * 434 * The default binding is <kbd>Tab</kbd>. 435 */ 436 gulong addOnToggleHandleFocus(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 437 { 438 return Signals.connect(this, "toggle-handle-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED); 439 } 440 }